<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>入库列表</title>
	<%--静态包含base标签，css，jQuery文件，--%>
	<%@include file="/view/common/head.jsp"%>
	<style>
		.hidden_scroll{
			/*border: 1px solid red;*/
			height: 370px;
			overflow: hidden;
			width: 700px;
			position: relative;
		}
		.table_div{
			/*border: 1px solid red;*/
			height: 370px;
			overflow-y: auto;
			position: absolute;
			right:-20px;

		}
		#main .table_div table{
			margin-top: 10px;
		}
		.width_tr>th{
			font-size: 22px;
			width: 140px !important;
		}
		.width_tr>th:last-child{
			width: 140px !important;
			/*padding-right: 23px;*/
		}
		.width_td{
			width:75px !important;
		}
	</style>
	<script type="text/javascript">
		$(function (){
			//给删除绑定单击事件
			$(".deleteItem").click(function (){
				return confirm("你确定要删除【" + $(this).parent().parent().find("td:first").text() + "】吗？")
			});
			//给清空入库列表绑定单击事件
			$("#clearList").click(function (){
				return confirm("你确定要清空入库列表吗？")
			});
			//给修改框绑定失去修改事件
			$(".updateCount").change(function (){
				if(confirm("你确定要将【" + name + "】商品修改数量为：" + count + "吗？")){
					let id = $(this).attr("clothesId");
					location.href = "${basePath}listServlet?&status=1&action=updateCount&id=" + id + "&count=" + count;
				}else{
					this.value = this.defaultValue;
				}
			});
		})
	</script>
</head>
<body>
<%@include file="/view/common/back.jsp"%>
	<div id="header">
			<span class="wel_word">入库列表</span>
		<%--	静态包含登录成功之后的菜单--%>
		<%@include file="/view/common/login_success_menu.jsp"%>
		<div>
			<a style="display:inline-block;padding-top:5px;" href="goodsServlet?action=page">返回</a>
		</div>
	</div>
	
	<div id="main">
	
		<table>
			<tr class="width_tr">
				<th>商品名称</th>
				<th>数量</th>
				<th>单价</th>
				<th>金额</th>
				<th>操作</th>
		</table>
		<div class="hidden_scroll">
			<div class="table_div">
				<table>
					<tr>
						<th></th>
						<th></th>
						<th></th>
						<th></th>
						<th></th>
						<c:if test="${empty sessionScope.go_list.items}">
							<%--			如果入库列表为空--%>
						<tr>
							<td colspan="5" style="width:1000px">空空如也！！！<a href="goodsServlet?action=page">快去选择吧！</a></td>
						</tr>
						</c:if>
						<c:if test="${not empty sessionScope.go_list.items}">
							<c:forEach items="${sessionScope.go_list.items}" var="entry">
								<tr>
									<td>${entry.value.name}</td>
									<td>
										<input clothesId="${entry.value.id}" class="updateCount" type="text" style="width: 50px;border:silver;" value="${entry.value.count}">
									</td>

									<td>${entry.value.price}</td>
									<td>${entry.value.totalPrice}</td>
									<td><a class="deleteItem" href="listServlet?action=deleteItem&status=1&id=${entry.value.id}">删除</a></td>
								</tr>
							</c:forEach>
						</c:if>
				</table>
			</div>
		</div>


		<c:if test="${not empty sessionScope.go_list.items}">
			<div class="list_info">
				<span class="list_span">入库列表中共有<span class="b_count">${sessionScope.go_list.totalCount}</span>件商品</span>
				<span class="list_span">总金额<span class="b_price">${sessionScope.go_list.totalPrice}</span>元</span>
				<span class="list_span"><a id="clearList" href="listServlet?&status=1&action=clear">清空入库列表</a></span>
				<span class="list_span"><a href="orderServlet?&status=1&action=createOrder">生成订单</a></span>
			</div>
		</c:if>
	</div>


	<%@include file="/view/common/footer.jsp"%>
</body>
</html>